#!/usr/bin/env python
#
# CUBudget: http://code.google.com/p/cubudget
# Copyright (c) 2008 Clemson University
# Released under the GNU GPL, version 2.
import cubudget

class Health_Check (object):

    def __init__(self, coreobj):
        self.theCore = coreobj
        self.balance = 0
        self.alerts = {}

    def __repr__(self):
        temp = len(self.alerts)
        return str(self.alerts)

    # gets balance from the core then returns the current balance
    def getBalance(self, curAccount):
        return  self.theCore.getAccountBalance(curAccount);

    # Currently not needed
    # Check all alerts for the current account
    def checkAlerts(self, curAccount):
        pass
    # Currently not needed    
    # Account defined alert from GUI
    def setAlert(self, alert_type, value):
        pass

    # go through list of accounts and check alerts on all account
    def checkAccount(self):
        account = self.theCore.getAllAccounts()

        for eachAccount in account:
            self.balance = self.getBalance(eachAccount)

            if self.balance <= 0:
                self.alerts[eachAccount] = "Balance: Below Zero"

            else:
                self.alerts[eachAccount] = ""
